package com.philosophy.web.controller;

import com.philosophy.web.service.VisitService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

/**
 * @author philosophy
 */
@Controller
public class VisitController {
    @Resource
    private VisitService visitService;

    @GetMapping("short/url/index")
    public String index() {
        return "index";
    }

    @GetMapping("{shortUrl}")
    public String redirect(@PathVariable String shortUrl) {
        String originUrl = visitService.getOriginUrl(shortUrl);
        return "redirect:" + originUrl;
    }

}
